<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>入职登记</title>
		<%include("/common/include.html"){}%>
		<style type="text/css">
			ul li{
				display: inline-block;
				margin-left: 40px;
				margin-top:10px;
			}
			
		</style>
	</head>
	<body>
	<form id="intoPerForm"   method="post"  enctype="multipart/form-data">
		<ul style="border: 1px solid #CCCCCC;margin:0 auto;width: 800px;position: relative;padding: 10px 0;">
			<input id = "personnelIds" type="hidden" name="intoPersonnel.userIds" value="${user.ids! }">
			<li style="margin-left: 39px">
				<span>职位（岗位）</span>
				<input class="easyui-textbox theme-textbox-radius date" style="width: 110px;height: 25px;"value="${user.station.name! }" disabled="true">
			</li>
			<li style="margin-left: 40px;">
				<span>填表日期</span>
				<input  name="intoPersonnel.fillingDate" class="easyui-datebox inputBox theme-textbox-radius date" data-options="sharedCalendar:'#cc'" style="height: 25px;width: 110px;"value="${intoPersonnel.fillingDate! }">
			</li>
			<br />	
			<li style="margin-left: 88px;">
				<span>姓名</span>
				<input class="easyui-textbox theme-textbox-radius date" style="width: 110px;height:25px;text-align: center;" value="${user.name! }" disabled="true">
			</li>		
			<li style="margin-left: 63px;">
				<span>性别</span>
				<select name="intoPersonnel.sex" class="easyui-combobox theme-textbox-radius" style="width: 110px;height:25px;text-align: center;" >
				<option value="男"  
							<% if(intoPersonnel.sex! == '男'){ %>
								selected="selected"
							<% } %>
						>男</option>
						<option value="女"  
							<% if(intoPersonnel.sex! == '女'){ %>
								selected="selected"
							<% } %>
						>女</option>
			
				
				</select>
			</li>
			<li style="margin-left: 65px;">
				<span>出生日期</span>
				<input name="intoPersonnel.personnel_birthday" class="easyui-datebox inputBox theme-textbox-radius date" data-options="sharedCalendar:'#cc'" style="height: 25px;width: 110px;"value="${intoPersonnel.personnel_birthday! }">
			</li>
			<li style="height: 140px;width: 120px;border: 1px solid #CCCCCC;position: absolute;right:10px;border-radius:5">
				<!-- <input name = "intoPersonnel.picture" id="zmfile"  name="zmfile"  class="easyui-filebox theme-textbox-radius"  onchange="imagePreview(this,1)"  style="width:140px" data-options="buttonText:'上传',prompt:'请选择'"> -->						
			</li>		
			<br />
			<li style="margin-left: 88px;margin-top: 5px">
				<span>身高</span>
				<input name="intoPersonnel.height" class="easyui-textbox theme-textbox-radius date" style="width: 110px;height:25px;text-align: center;"value="${intoPersonnel.height! }">
			</li>
			<li style="margin-left: 64px;">
				<span>体重</span>
				<input name="intoPersonnel.weight" class="easyui-textbox theme-textbox-radius date" style="width: 110px;height:25px;text-align: center;"value="${intoPersonnel.weight! }">
			</li>
			<li style="margin-left: 88px;">
				<span>民族</span>
				 <#code type="select" id="nation_select" name="intoPersonnel.nation" code="code_nation" defaultCode="${intoPersonnel.nation! }"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 110px;height:25px;text-align: center;"/>
			</li>
			<br />
			<li style="margin-left: 64px;margin-top: 5px">
				<span>政治面貌</span>
				 <#code type="select" id="zzmm_select" name="intoPersonnel.politics_status" code="code_zzmm" defaultCode="${intoPersonnel.politics_status! }"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 110px;height:25px;text-align: center;"/>
			</li>
			<li style="margin-left: 40px;">
				<span>婚姻状况</span>
				 <#code type="select" id="hyzk_select" name="intoPersonnel.marital_status" code="code_marry" defaultCode="${intoPersonnel.marital_status! }"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 110px;height: 25px;"/> 
				
			</li>
			<li style="margin-left: 64px;">
				<span>健康状况</span>
				 <#code type="select" id="hyzk_select" name="intoPersonnel.health_condition" code="code_jkzk" defaultCode="${intoPersonnel.health_condition! }"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 110px;height: 25px;"/> 
				
			</li>
			<br />
			<li style="margin-left: 88px;margin-top: 5px">
				<span>专业</span>
				<input name="intoPersonnel.major" class="easyui-textbox theme-textbox-radius date"  style="width: 110px;height: 25px;"value="${intoPersonnel.major! }">
					
			</li>
			<li style="margin-left: 64px;">
				<span>学历</span>
				<#code type="select" id="xl_select" name="intoPersonnel.education_background" code="code_xl" defaultCode="${intoPersonnel.education_background! }"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 110px;height:25px;text-align: center;"/>
			</li>
			<li style="margin-left: 52px;">
				<span>计算机水平</span>
				<#code type="select" id="xl_select" name="intoPersonnel.computer_skill" code="code_jsjsp" defaultCode="${intoPersonnel.computer_skill! }"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 110px;height:25px;text-align: center;"/>
				
			</li>
			<br />
			<li style="margin-left: 64px;margin-top: 5px">
				<span>毕业学校</span>
				<input name="intoPersonnel.graduation_school" class="easyui-textbox theme-textbox-radius date" style="width: 110px;height: 25px;"value="${intoPersonnel.graduation_school! }">
			</li>
			<li style="margin-left: 40px;">
				<span>身份证号</span>
				<input id = "idCard" name="intoPersonnel.idcard"class="easyui-textbox theme-textbox-radius date" style="width: 110px;height: 25px;"value="${intoPersonnel.idcard! }">		
			</li>
			<li style="margin-left: 76px;">
				<span>手机号</span>
				<input class="easyui-textbox theme-textbox-radius date" style="width: 110px;height: 25px;"value="${user.mobile! }" disabled="true">
					
			</li>
			<br />
			<li style="margin-left: 64px;">
						<span>联系住址</span>
							 <#code type="select" id="xzqh_select" name="intoPersonnel.province" code="code_xzqh" defaultCode="${intoPersonnel.province! }"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 133px;height: 25px;"/>
								<input id="city_input" type="hidden" value="${intoPersonnel.city !}" >
								<input id="city_combobox"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 133px;height: 25px;"/>
								<input id="area_input" type="hidden" value="${intoPersonnel.area !}">
								<input id="area_combobox" name="intoPersonnel.area" class="easyui-combobox inputBox theme-textbox-radius" style="width: 133px;height: 25px;"/>
								<input class="easyui-textbox theme-textbox-radius" name="intoPersonnel.personnel_address" style="width: 133px;height: 25px;" value="${intoPersonnel.personnel_address !}"/>
					</li>						
			<br />
			<li style="margin-left: 16px;margin-top: 5px">
				<span>是否公司员工介绍</span>
				<select id="introduce" name="intoPersonnel.introduce" class="easyui-combobox theme-textbox-radius" style="width: 200px;height: 25px;"value="${intoPersonnel.introduce! }">
					<option value="0"  
							<% if(intoPersonnel.introduce! == '0'){ %>
								selected="selected"
							<% } %>
						>是</option>
						<option value="1"  
							<% if(intoPersonnel.introduce! == '1'){ %>
								selected="selected"
							<% } %>
						>否</option>
					
				</select>
			</li>
			<li style="margin-left: 101px;">
				<span>介绍人</span>

				<input id="jsr" name="intoPersonnel.jsrName"class="easyui-textbox theme-textbox-radius date" style="width: 200px;height: 25px;"value="${intoPersonnel.jsrName! }">

			
			</li>
			<br />
			<li style="margin-left: 16px;margin-top: 5px">
				<span>执行公司薪资级别</span>
				<#code type="select" id="xl_select" name="intoPersonnel.salary_level" code="code_xzjb" defaultCode="${intoPersonnel.salary_level! }"  class="easyui-combobox inputBox theme-textbox-radius" style="width: 200px;height:25px;"/>
				
			</li>
			<li style="margin-left: 89px;">
				<span>自我评价</span>
				<input name="intoPersonnel.self_assessment" class="easyui-textbox theme-textbox-radius date" style="width: 200px;height: 25px;"value="${intoPersonnel.self_assessment! }">					
			</li>
			</form>
			<!-- <form id="intoExp"   method="post"  enctype="multipart/form-data"> -->
				<p style="height: 5px;"></p>
				<div id="cc" class="easyui-calendar"></div>
				<table id="experience" class="easyui-datagrid" title="工作经历" style="width:100%;height:auto">
							
				 </table>	
				  <div id="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newExperience()">添加</a>
       <!--  <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editExperience()">修改</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyExperience()">删除</a> -->
    </div>
					
			  <div id="dlg" class="easyui-dialog" style="width:400px"
            closed="true" buttons="#dlg-buttons">
        <form id="fm" method="post" novalidate style="margin:0;padding:20px 50px">
            <div style="margin-bottom:20px;font-size:14px;border-bottom:1px solid #ccc">工作经验</div>
            <div style="margin-bottom:10px">
                <input name="intoExperience.startTime" class="easyui-datebox inputBox theme-textbox-radius date" data-options="sharedCalendar:'#cc'"  required="true" label="开始时间" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoExperience.endTime" class="easyui-datebox inputBox theme-textbox-radius date" data-options="sharedCalendar:'#cc'"  required="true" label="结束时间" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoExperience.workUnit" class="easyui-textbox" required="true" label="工作单位" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoExperience.position" class="easyui-textbox" required="true"  label="工作职位" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoExperience.mainTask" class="easyui-textbox" required="true"  label="主要工作" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoExperience.dimissionReason" class="easyui-textbox" required="true"  label="离职原因" style="width:100%">
            </div>
            <div id="allData" style="display:none;"></div>
        </form>
    </div>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveExperience()" style="width:90px">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">取消</a>
    </div>
			
				 <table id="relationShip" class="easyui-datagrid" title="直系亲属" style="width:100%;height:auto">
							
				</table> 
				 <div id="rel-toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newRelation()">添加</a>
      
    </div>
				
			  <div id="rel-dlg" class="easyui-dialog" style="width:400px"
            closed="true" buttons="#rel-dlg-buttons">
        <form id="Relfm" method="post" novalidate style="margin:0;padding:20px 50px">
            <div style="margin-bottom:20px;font-size:14px;border-bottom:1px solid #ccc">直系亲属</div>
           
            <div style="margin-bottom:10px">
                <input name="intoRelationship.relationship" class="easyui-textbox" required="true" label="关系" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoRelationship.name" class="easyui-textbox" required="true"  label="姓名" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoRelationship.age" class="easyui-textbox" required="true"  label="年龄" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoRelationship.workUnit" class="easyui-textbox" required="true"  label="工作单位" style="width:100%">
            </div>
            <div style="margin-bottom:10px">
                <input name="intoRelationship.position" class="easyui-textbox" required="true"  label="职位" style="width:100%">
            </div>
            <div id="allData2" style="display:none;"></div>
        </form>
    </div>
    <div id="rel-dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveRelation()" style="width:90px">保存</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#rel-dlg').dialog('close')" style="width:90px">取消</a>
    </div> 
			
			<li style="margin-left: 40px;margin-top: 5px">
				<span>用人部门意见</span>
				<select name="intoPersonnel.employer_opinion" class="easyui-combobox theme-textbox-radius" style="width: 110px;height: 25px;">
					<option value="同意">同意</option>
					<option value="不同意">不同意</option>
				</select>
			</li>
			<li style="margin-left: 29px;">
				<span>人事部意见</span>
				<select name="intoPersonnel.personnel_department_opinion" class="easyui-combobox theme-textbox-radius" style="width: 110px;height: 25px;">
					<option value="同意">同意</option>
					<option value="不同意">不同意</option>
				</select>
			</li>
			<li style="margin-left: 39px;">
				<span>公司领导审批</span>
				<select name="intoPersonnel.leadership" class="easyui-combobox theme-textbox-radius" style="width: 110px;height: 25px;">
					<option value="同意">同意</option>
					<option value="不同意">不同意</option>
				</select>
			</li>
		</ul>	
			
		 
			
		<script src="${cxt !}/sb/js/ajaxfileupload.js" type="text/javascript" charset="utf-8"></script>
		<script src="${cxt !}/sb/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">	
		$(document).ready(function () {
			loadDatagrid();
			loadDatagrid2();
		})
		//省份改变选择城市
		$('#xzqh_select').combobox({

			onChange: function (n,o) {
				getCity(n);
			},
		onSelect: function (n) 
		 {		
			 var newPtion = $('#xzqh_select').combobox('getValue');
			 getCity(newPtion);
		 }

		});
		//市改变选择区
		$('#city_combobox').combobox({

			onChange: function (n,o) {
				getArea(n);
			}
			
		});
		//获取城市
		function  getCity(n)
		{
			var url = "/bentryRegister/getChild";
			var data={"codeIds":n};
			var reData = common_ajax.ajaxFunc(url,data,"json");
			var city=$("#city_input").val();
			var com=$('#city_combobox');
			select(reData,com,city);
		}
		//获取区
		function  getArea(n)
		{
			var url = "/bentryRegister/getChild";
			var data={"codeIds":n};
			var reData = common_ajax.ajaxFunc(url,data,"json");
			var area=$("#area_input").val();
			var com=$('#area_combobox');
			select(reData,com,area);
		}
		function select(reData,com,info)
		{	
			com.combobox({
				  data:reData,
				  valueField:'ids', 
	          	  textField:'name',
		          onLoadSuccess: function () {
		        	  if(info!="")
						 {
							 var val = $(this).combobox('getData'); 
		        	  		  for(var i=0;i<val.length;i++)
		        	  		  {		
		        	  			  if(val[i].ids==info)
		        	  			  {
		        	  				$(this).combobox('select', val[i].ids); 
		        	  			  }
		        	  		  }
						 }else
						 {
							 var val = $(this).combobox('getData');  
	                         for (var item in val[0]) {  
	                             if (item == 'ids') {  
	                                 $(this).combobox('select', val[0][item]);  
	                             }  
	                         } 
						 }
		          }	
	            
			});
			
		}
		 var url;
	        function newExperience(){
	        	
	          $('#dlg').dialog('open').dialog('center').dialog('setTitle','添加工作经验');
	            $('#fm').form('clear'); 
	           
	            url = '${cxt !}/intoPersonnel/saveExp';
	        }
	        
	        function saveExperience(){
	        	 var personnelIds = $("#personnelIds").val();
	        	
	        	$("#allData").append("<input type='hidden' name='intoExperience.personnelIds' value='"+personnelIds+"'/>");
	            $('#fm').form('submit',{
	                url: url,
	                onSubmit: function(){
	                    return $(this).form('validate');
	                },
	                success: function(result){
	                    var result = eval('('+result+')');
	                    if (result.errorMsg){
	                        $.messager.show({
	                            title: 'Error',
	                            msg: result.errorMsg
	                        });
	                    } else {
	                        $('#dlg').dialog('close');        // close the dialog
	                        $('#experience').datagrid('reload');    // reload the user data
	                    }
	                }
	            });
	        }
	        
	        function newRelation(){
	        	
		          $('#rel-dlg').dialog('open').dialog('center').dialog('setTitle','添加直系亲属');
		            $('#Relfm').form('clear'); 
		           
		            url = '${cxt !}/intoPersonnel/saveRel';
		        }
		        
		        function saveRelation(){
		        	 var personnelIds = $("#personnelIds").val();
		        	
		        	$("#allData2").append("<input type='hidden' name='intoRelationship.personnelIds' value='"+personnelIds+"'/>");
		            $('#Relfm').form('submit',{
		                url: url,
		                onSubmit: function(){
		                    return $(this).form('validate');
		                },
		                success: function(result){
		                    var result = eval('('+result+')');
		                    if (result.errorMsg){
		                        $.messager.show({
		                            title: 'Error',
		                            msg: result.errorMsg
		                        });
		                    } else {
		                        $('#rel-dlg').dialog('close');        // close the dialog
		                        $('#relationShip').datagrid('reload');    // reload the user data
		                    }
		                }
		            });
		        }
		
            
            function  loadDatagrid()
            {
            $('#experience').datagrid({
                cls: "theme-datagrid",
                singleSelect: true,
                
                rownumbers: true, //显示序号
                fitColumns:true,
                pagination: false,
                //pageSize: 10,
               // onClickRow: onClickRow,
                url: "intoPersonnel/personnelList",
				
				queryParams: {
			
					'personnelIds':$("#personnelIds").val() 
				},
                method: 'post',
                collapsible: true,
                columns:[[	
                      		{field:'starttime',title:'开始时间',width:100,align:'center'},
                      		{field:'endtime',title:'结束时间',width:100,align:'center'},
                      		{field:'workunit',title:'工作单位',width:100,align:'center'},
                      		{field:'position',title:'职位',width:100, align:'center'},
                      		{field:'maintask',title:'主要工作',width:100, align:'center'},
                      		{field:'dimissionreason',title:'离职原因',width:100, align:'center'},
                          ]]
                }),
                toolbar="#toolbar"
            }
            function  loadDatagrid2()
            {
            $('#relationShip').datagrid({
                cls: "theme-datagrid",
                singleSelect: true,
                rownumbers: true, //显示序号
                fitColumns:true,
                pagination: false,
               // pageSize: 10,
               // onClickRow: onClickRow,
                url: "intoPersonnel/relList",
                queryParams: {
                	'personnelIds':$("#personnelIds").val() 
                },
                method: 'post',
                collapsible: true,
                columns:[[	
                      		{field:'relationship',title:'关系',width:100,align:'center'},
                      		{field:'name',title:'姓名',width:100,align:'center'},
                      		{field:'workunit',title:'工作单位',width:100,align:'center'},
                      		{field:'position',title:'职位',width:100, align:'center'},
                      		{field:'age',title:'年龄',width:100, align:'center'},
                      		
                          ]]
                }),
                toolbar="#rel-toolbar"
            }
				var submitNow = function($dialog, $grid, $tree, $pjq) {
					var url = "${cxt !}/intoPersonnel/saveIntoPer";
					//upload();
					$.post(url, sy.serializeObject($('#intoPerForm')), function(result) {
						if (result.msg == '200') {
							$.slideMsg("修改成功！", $pjq);		
							
						} else {
							$.alert($pjq, result.msg);
						}
					}, 'json');
					
				};
				var submitForm = function($dialog, $grid, $tree, $pjq) {
					submitNow($dialog, $grid, $tree, $pjq);
					// 					$form.isValid(function(isValied){
					// 						if(isValied){
					// 							submitNow($dialog, $grid, $pjq);
					// 						}
					// 					});
				};
				
				
				
				
				//--------上传图片
				function upload()
				{	
				
				
					var personnelIds = $("#personnelIds").val();
					//alert(personnelIds);
					 $.ajaxFileUpload({
					        url : '${cxt !}/intoPersonnel/imageUpload',   //提交的路径
					        secureuri : false, // 是否启用安全提交，默认为false
					        fileElementId :['zmfile','cmfile'], // file控件id
// 					         fileElementId :'zmfile',
					        dataType : 'json',
					        data : { personnelIds : personnelIds}, // 键:值，传递文件名
					        
					        success : function(result, status) {
					      
					        	if (result.status == 0) {
					        		$.slideMsg("保存成功", parent.$);

					            } 
					        	if(result.status == 1){
					        		
					                $.alert(parent.$, result.message);
					            }
					        	if(result.status == 2)
					        	{
					        		$.slideMsg(result.message, parent.$);
					        	}
					        },
					        error : function(data, status) {
					        	$.alert(parent.$, "只允许上传png,jpg,jpeg,gif,bmp类型的图片文件！");
					        }
					    });
				}
				
				function  imagePreview(obj,type)
				{	
					var $file =$(obj);
					var fileObj = $file[0];
					var windowURL = window.URL || window.webkitURL;
					var dataURL;
					var $img;
					if(type==1)
					{
						$img = $("#zmpicture");
					}
					if(type==2)
					{
						$img = $("#cmpicture");
					}
// 					var $img = $("#zmpicture");
					 
					if(fileObj && fileObj.files && fileObj.files[0]){
					dataURL = windowURL.createObjectURL(fileObj.files[0]);
					$img.attr('src',dataURL);
					}else{
					dataURL = $file.val();
					var imgObj = document.getElementById("preview");
					// 两个坑:
					// 1、在设置filter属性时，元素必须已经存在在DOM树中，动态创建的Node，也需要在设置属性前加入到DOM中，先设置属性在加入，无效；
					// 2、src属性需要像下面的方式添加，上面的两种方式添加，无效；
					imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
					imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;
					 }
				}
				function  chakan()
				{
					$('#picture').window('open');
					$('#zmpicture').css("display","block");
				
					
					
				}
				//是否公司员工介绍内容改变时
				$(document).ready(function () {
					$('#introduce').combobox({
						onChange:function(){
							if ($('#introduce').combobox('getValue')=="1"){ 
								$("#jsr").combobox({readonly:true});
								$("#jsr").combobox('setValue',"无");
							}else{
								$("#jsr").combobox({readonly:false});
							}
				
						}
					}) 
				});
				
				
	
				
		</script>	
	</body>
</html>
